<?php
/**
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * @package Shipping_Agent
 * @copyright Copyright 2010 Structured Solutions
 * @license http://shippingagent.codeplex.com/license MIT License (MIT)
 * @version 3.7
 */

// Turn off wsdl caching while making changes to the definition or implementation.
ini_set("soap.wsdl_cache_enabled", "1");

if (isset($HTTP_RAW_POST_DATA))
	$request = $HTTP_RAW_POST_DATA;
else 
	$request = file_get_contents("php://input");

/**
 * Load Magento
 */
require_once 'app/Mage.php';
Mage::app();

/**
 * Let Magento load the SOAP server implementation
 */
$model = Mage::getModel("StructuredSolutions_ShippingAgent_Model_Server");

/**
 * Handle the request
 */
if ($request == "" && !isset($_GET["wsdl"]) && !isset($_GET["WSDL"]))
{
	echo "This Shipping Agent for Magento Commerce implements contract version "
        . StructuredSolutions_ShippingAgent_Model_Server::VERSION . ".";
}
else 
{
    $server = $model->getSoapServer();
	$server->handle($request);
}
?>